Subroutines provide a way to perform a particular function at any point in a software program without duplicating the code which implements the function. Whenever a subroutine is called, the current location in the calling program flow is preserved and the subroutine is executed. After the completion of the subroutine, the calling program is resumed at the location where it left off. A calling program is able to pass parameters to a subroutine and retrieve return values upon completion. Subroutines are typically implemented with the help of subroutine stacks. These stacks are Last-In-First-Out memory buffers which serve to store call parameters, return values, the return address of the calling software program, as well as local variables. Subroutine stacks are vulnerable to many security and safety problems. Security problems typically manifest themselves in external attacks, such as stack buffer overflow attacks, where the attacker intentionally manipulates the saved return address of the subroutine to gain control over the computing system as the subroutine terminates execution and returns control to the software program. Safety problems are unintended stack manipulation caused by software or hardware faults. These stack manipulations may have severe impact on the system integrity. In particular these stack manipulations provide a way for immature code segments to affect the functionality of mature code segments. While there are existing protection schemes against the mentioned security problems (e.g., software solutions using the insertion of canary codes), these only offer limited stack protection. Most computing systems don't provide any protection against the safety issues. Common protecting mechanisms like memory protection units (MPU) provide access restrictions on static memory ranges and are not suited for the dynamic boundaries required for the protection of subroutine stacks.
Therefore, in view of the lack of appropriate protection techniques, there is a need to provide for the dynamic protection of subroutine stacks.
For instance, the stack is often used by a main program to dynamically store parameters in the provided space, for use by subroutine(s) of the main program. Such stacks are called subroutine stacks. Therefore, in view of the lack of appropriate protection techniques, there is a need to provide for the dynamic protection of subroutine stacks.